package com.salary.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.common.util.ExtjsAjaxResponse;
import com.salary.entity.SalaryFormula;
import com.salary.entity.dto.CountDayDTO;
import com.salary.entity.dto.SalaryFormulaDTO;
import com.salary.service.ISalaryFormulaService;

@Controller
@RequestMapping("/salaryFormula")
public class SalaryFormulaController {
	@Autowired
	private ISalaryFormulaService salaryFormulaService;
	
	@RequestMapping("/findAll")
	public @ResponseBody List<SalaryFormulaDTO> findAll(){
		return salaryFormulaService.findDTO();
	}
	@RequestMapping("/saveOrUpdate")
	public @ResponseBody ExtjsAjaxResponse saveOrUpdate(SalaryFormulaDTO dto) {
		try {
			salaryFormulaService.saveOrUpdate(dto);
			return new ExtjsAjaxResponse(true,"操作成功！");
		} catch (Exception e) {
			return new ExtjsAjaxResponse(false,"操作失败！");
		}
		
	}
	@RequestMapping("/findCountDay")
	public @ResponseBody List<CountDayDTO> findCountDay() {
		try {
			return salaryFormulaService.findCountDayDTO();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
	@RequestMapping("/setCountDay")
	public @ResponseBody ExtjsAjaxResponse setCountDay(Integer countDay) {
		try {
			salaryFormulaService.setCountDay(countDay);
			return new ExtjsAjaxResponse(true,"操作成功！");
		} catch (Exception e) {
			e.printStackTrace();
			return new ExtjsAjaxResponse(true,"操作失败！");
		}
		
	}
}
